<?php
    include_once($_SERVER['DOCUMENT_ROOT'].'/mba/models/Database.php');
	
    class MBA extends Database{
		// thong tin chinh
		private $MSTS;
		private $SO_N0;
		private $MA_DIEN_AP;
		private $LOAI_DIEN_AP;
		private $MA_NSX;
		private $TEN_NSX;
		private $NUOC_SX;
		private $MA_LOAI;
		private $CONG_SUAT;
		private $CHIEU_DAI;
		private $CHIEU_RONG;
		private $CHIEU_CAO;
		private $RUOT_MAY;
		private $DAU_MAY;
		private $TONG;
		private $NAM_SX;
		private $NAM_NHAP_VE;
		private $THONG_SO_DO;
		private $NHAN_XET;
		private $GHI_CHU;
		
		// thong tin phu
		
		// bang chi_tiet_ngung_van_hanh
		private $NGAY_NGUNG_VH;
		// bang chi_tiet_so_huu
		private $MA_DON_VI;
		private $TEN_DON_VI;
		private $NGAY_CHUYEN_DEN;
		// bang chi_tiet_tt_may
		private $TEN_TINH_TRANG_MAY;
		private $DG_TINH_TRANG;
		private $TINH_TRANG_NGAY;
		// bang loai_dien_ap
		private $CAP_DIEN_AP;
		// bang loai_may
		private $TEN_LOAI;
		// bang loai_dau
		private $MA_LOAI_DAU;
		private $TEN_LOAI_DAU;
		// bang chi_tiet_dai_tu
		private $NGAY_DAI_TU;
		// bang mba_tram
		private $MA_TRAM;
		private $TEN_TRAM;
		private $NGAY_VAN_HANH;
		// bang nuoc_sx
		private $TEN_NUOC;
		
		
		
		public function setMSTS($MSTS){
			$this->MSTS = $MSTS;
			}
		public function getMSTS(){
			return $this->MSTS;
			}
        
        public function setSO_N0($SO_N0){
            $this->SO_N0 = $SO_N0;
        }
        public function getSO_N0(){
            return $this->SO_N0;
        }
		
		 public function setMA_DIEN_AP($MA_DIEN_AP){
            $this->MA_DIEN_AP = $MA_DIEN_AP;
        }
		public function getMA_DIEN_AP(){
            return $this->MA_DIEN_AP;
        }
		
		public function setLOAI_DIEN_AP($LOAI_DIEN_AP){
            $this->LOAI_DIEN_AP = $LOAI_DIEN_AP;
        }
		public function getLOAI_DIEN_AP(){
            return $this->LOAI_DIEN_AP;
        }
		
		
		 public function setMA_NSX($MA_NSX){
            $this->MA_NSX = $MA_NSX;
        }  
		public function getMA_NSX(){
            return $this->MA_NSX;
        }
		
		
		public function setTEN_NSX($TEN_NSX){
            $this->TEN_NSX = $TEN_NSX;
        }  
		public function getTEN_NSX(){
            return $this->TEN_NSX;
        }
		
		public function setNUOC_SX($NUOC_SX){
            $this->NUOC_SX = $NUOC_SX;
        }  
		public function getNUOC_SX(){
            return $this->NUOC_SX;
        }
		
		public function setMA_LOAI($MA_LOAI){
			$this->MA_LOAI = $MA_LOAI;
		}
		public function getMA_LOAI(){
			return $this->MA_LOAI;
		}
		
		public function setCONG_SUAT($CONG_SUAT){
			$this->CONG_SUAT = $CONG_SUAT;
		}
		public function getCONG_SUAT(){
			return $this->CONG_SUAT;
		}
		
		public function setCHIEU_DAI($CHIEU_DAI){
			$this->CHIEU_DAI = $CHIEU_DAI;
		}
		public function getCHIEU_DAI(){
			return $this->CHIEU_DAI;
		}
		
		
		public function setCHIEU_RONG($CHIEU_RONG){
			$this->CHIEU_RONG = $CHIEU_RONG;
		}
		public function getCHIEU_RONG(){
			return $this->CHIEU_RONG;
		}
		
		public function setCHIEU_CAO($CHIEU_CAO){
			$this->CHIEU_CAO = $CHIEU_CAO;
		}
		public function getCHIEU_CAO(){
			return $this->CHIEU_CAO;
		}
		
		public function setRUOT_MAY($RUOT_MAY){
			$this->RUOT_MAY = $RUOT_MAY;
		}
		public function getRUOT_MAY(){
			return $this->RUOT_MAY;
		}
		
		public function setDAU_MAY($DAU_MAY){
			$this->DAU_MAY = $DAU_MAY;
		}
		public function getDAU_MAY(){
			return $this->DAU_MAY;
		}
		
		public function setTONG($TONG){
			$this->TONG = $TONG;
		}
		public function getTONG(){
			return $this->TONG;
		}
		
		public function setNAM_SX($NAM_SX){
			$this->NAM_SX = $NAM_SX;
		}
		public function getNAM_SX(){
			return $this->NAM_SX;
		}
		
		public function setNAM_NHAP_VE($NAM_NHAP_VE){
			$this->NAM_NHAP_VE = $NAM_NHAP_VE;
		}
		public function getNAM_NHAP_VE(){
			return $this->NAM_NHAP_VE;
		}
		
		public function setTHONG_SO_DO($THONG_SO_DO){
			$this->THONG_SO_DO = $THONG_SO_DO;
		}
		public function getTHONG_SO_DO(){
			return $this->THONG_SO_DO;
		}
		
		public function setNHAN_XET($NHAN_XET){
			$this->NHAN_XET = $NHAN_XET;
		}
		public function getNHAN_XET(){
			return $this->NHAN_XET;
		}
		
		public function setGHI_CHU($GHI_CHU){
			$this->GHI_CHU = $GHI_CHU;
		}
		public function getGHI_CHU(){
			return $this->GHI_CHU;
		}
		
		public function setNGAY_DAI_TU($NGAY_DAI_TU){
			$this->NGAY_DAI_TU = $NGAY_DAI_TU;
		}
		public function getNGAY_DAI_TU(){
			return $this->NGAY_DAI_TU;
		}
		
		public function setNGAY_NGUNG_VH($NGAY_NGUNG_VH){
			$this->NGAY_NGUNG_VH = $NGAY_NGUNG_VH;
		}
		public function getNGAY_NGUNG_VH(){
			return $this->NGAY_NGUNG_VH;
		}
		
		public function setMA_DON_VI($MA_DON_VI){
			$this->MA_DON_VI = $MA_DON_VI;
		}
		public function getMA_DON_VI(){
			return $this->MA_DON_VI;
		}
		
		public function setTEN_DON_VI($TEN_DON_VI){
			$this->TEN_DON_VI = $TEN_DON_VI;
		}
		public function getTEN_DON_VI(){
			return $this->TEN_DON_VI;
		}
		
		public function setNGAY_CHUYEN_DEN($NGAY_CHUYEN_DEN){
			$this->NGAY_CHUYEN_DEN = $NGAY_CHUYEN_DEN;
		}
		public function getNGAY_CHUYEN_DEN(){
			return $this->NGAY_CHUYEN_DEN;
		}
		
		public function setTEN_TINH_TRANG_MAY($TEN_TINH_TRANG_MAY){
			$this->TEN_TINH_TRANG_MAY = $TEN_TINH_TRANG_MAY;
		}
		public function getTEN_TINH_TRANG_MAY(){
			return $this->TEN_TINH_TRANG_MAY;
		}
		
		public function setDG_TINH_TRANG($DG_TINH_TRANG){
			$this->DG_TINH_TRANG = $DG_TINH_TRANG;
		}
		public function getDG_TINH_TRANG(){
			return $this->DG_TINH_TRANG;
		}
		public function setTINH_TRANG_NGAY($TINH_TRANG_NGAY){
			$this->TINH_TRANG_NGAY = $TINH_TRANG_NGAY;
		}
		public function getTINH_TRANG_NGAY(){
			return $this->TINH_TRANG_NGAY;
		}
		public function setCAP_DIEN_AP($CAP_DIEN_AP){
			$this->CAP_DIEN_AP = $CAP_DIEN_AP;
		}
		public function getCAP_DIEN_AP(){
			return $this->CAP_DIEN_AP;
		}
		public function setTEN_LOAI($TEN_LOAI){
			$this->TEN_LOAI = $TEN_LOAI;
		}
		public function getTEN_LOAI(){
			return $this->TEN_LOAI;
		}
		
		public function setMA_LOAI_DAU($MA_LOAI_DAU){
			$this->MA_LOAI_DAU = $MA_LOAI_DAU;
		}
		public function getMA_LOAI_DAU(){
			return $this->MA_LOAI_DAU;
		}
		
		public function setTEN_LOAI_DAU($TEN_LOAI_DAU){
			$this->TEN_LOAI_DAU = $TEN_LOAI_DAU;
		}
		public function getTEN_LOAI_DAU(){
			return $this->TEN_LOAI_DAU;
		}
		
		public function setMA_TRAM($MA_TRAM){
			$this->MA_TRAM = $MA_TRAM;
		}
		public function getMA_TRAM(){
			return $this->MA_TRAM;
		}
		
		public function setTEN_TRAM($TEN_TRAM){
			$this->TEN_TRAM = $TEN_TRAM;
		}
		public function getTEN_TRAM(){
			return $this->TEN_TRAM;
		}
		
		
		public function setNGAY_VAN_HANH($NGAY_VAN_HANH){
			$this->NGAY_VAN_HANH = $NGAY_VAN_HANH;
		}
		public function getNGAY_VAN_HANH(){
			return $this->NGAY_VAN_HANH;
		}
		
	
		
		public function setTEN_NUOC($TEN_NUOC){
			$this->TEN_NUOC = $TEN_NUOC;
		}
		public function getTEN_NUOC(){
			return $this->TEN_NUOC;
		}
		
		
		
		
		 public function themMBA(){
			 // them vao bang may_bien_ap
			$query = "insert into may_bien_ap(MSTS,SO_N0,MA_DIEN_AP,MA_NSX,MA_LOAI,CONG_SUAT,CHIEU_DAI,CHIEU_RONG,CHIEU_CAO,RUOT_MAY,DAU_MAY,TONG,NAM_SX,NAM_NHAP_VE,THONG_SO_DO,NHAN_XET,GHI_CHU)
			values ('".$this->getMSTS()."','".$this->getSO_N0()."','".$this->getMA_DIEN_AP()."','".$this->getMA_NSX()."','".$this->getMA_LOAI()."','".$this->getCONG_SUAT()."','".$this->getCHIEU_DAI()."','".$this->getCHIEU_RONG()."','".$this->getCHIEU_CAO()."','".$this->getRUOT_MAY()."','".$this->getDAU_MAY()."','".$this->getTONG()."','".$this->getNAM_SX()."','".$this->getNAM_NHAP_VE()."','".$this->getTHONG_SO_DO()."','".$this->getNHAN_XET()."','".$this->getGHI_CHU()."')";
            $this->setQuery($query);
			$this->executeQuery();
            
			
			// them vao bang chi_tiet_dai_tu
			if ($this->getNGAY_DAI_TU() != "") {
			$query = "insert into chi_tiet_dai_tu(SO_N0,NGAY_DAI_TU) 
            values ('".$this->getSO_N0()."','".$this->getNGAY_DAI_TU()."')";
            $this->setQuery($query);
			$this->executeQuery();
			}
			
			// them vao bang chi_tiet_ngung_van_hanh
			if ($this->getNGAY_NGUNG_VH() != "") {
			$query = "insert into chi_tiet_ngung_van_hanh(SO_N0,NGAY_NGUNG_VH) 
            values ('".$this->getSO_N0()."','".$this->getNGAY_NGUNG_VH()."')";
            $this->setQuery($query);
			$this->executeQuery();
			}
			
			// them vao bang chi_tiet_tt_may
			if ($this->getTEN_TINH_TRANG_MAY() != "") { 
			$query = "insert into chi_tiet_tt_may(TEN_TINH_TRANG_MAY,SO_N0,DG_TINH_TRANG,TINH_TRANG_NGAY) 
            values ('".$this->getTEN_TINH_TRANG_MAY()."','".$this->getSO_N0()."','".$this->getDG_TINH_TRANG()."','".$this->getTINH_TRANG_NGAY()."')";
			$this->setQuery($query);
			$this->executeQuery();
			}
			// them vao bang may_loai_dau-----------------------------------------------------
			
			$query = "insert into may_loai_dau(SO_N0,MA_LOAI_DAU) 
            values ('".$this->getSO_N0()."','".$this->getMA_LOAI_DAU()."')";
            $this->setQuery($query);
			$this->executeQuery();
			// bang mba_tram
			if ($this->getMA_TRAM() != ""){
			$query = "insert into mba_tram(MA_TRAM,SO_N0,NGAY_VAN_HANH) 
            values ('".$this->getMA_TRAM()."','".$this->getSO_N0()."','".$this->getNGAY_VAN_HANH()."')";
            $this->setQuery($query);
			$this->executeQuery();
			}
			// bang chi_tiet_so_huu
			$query = "insert into chi_tiet_so_huu(SO_N0,MA_DON_VI,NGAY_CHUYEN_DEN) 
            values ('".$this->getSO_N0()."','".$this->getMA_DON_VI()."','".$this->getNGAY_CHUYEN_DEN()."')";
            $this->setQuery($query);
			return $this->executeQuery();
		
			
			
        }
		
                
       // function sua thong tin don vi
        public function suaDV(){
            $query = "	update don_vi 
						set TEN_DON_VI='".$this->getTenDV()."',
						DIA_CHI_DV='".$this->getDiaChiDV()."',
						LIEN_HE_DV='".$this->getLienHeDV()."'
						where MA_DON_VI='".$this->getMaDV()."' ";
            $this->setQuery($query);
			$this->executeQuery();
			
			$query = "	update tai_khoan 
						set TEN_TK='".$this->getTenTK()."',
						MAT_KHAU='".$this->getMatKhau()."',
						QUYEN='".$this->getQuyen()."'
						where MA_DON_VI='".$this->getMaDV()."' ";
            $this->setQuery($query);
            return $this->executeQuery();  
        }
		// function xoa thong tin don vi
        public function xoaDV(){
            $this->setQuery("delete from don_vi where  MA_DON_VI='".$this->getMaDV()."'");
			$this->executeQuery();
			$this->setQuery("delete from tai_khoan where  MA_DON_VI='".$this->getMaDV()."'");
            return $this->executeQuery();
        }
     
        public function dsDonVi(){
            $this->setQuery("select don_vi.MA_DON_VI,TEN_DON_VI,DIA_CHI_DV,LIEN_HE_DV,TEN_TK,MAT_KHAU,QUYEN
							 from don_vi,tai_khoan
							 WHERE don_vi.MA_DON_VI=tai_khoan.MA_DON_VI");
            return $this->fetchAll();
        }
	
    }
?>